package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cheer.entity.OaUserEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户信息
 *
 * @author cheer
 */
@Mapper
@Repository
public interface OaUserDao extends BaseMapper<OaUserEntity> {

    @Select("select max(id) from oa_user")
    Integer selectMaxId();


    default Integer selectIdByOpenid(String openid) {
        OaUserEntity user = selectOne(new QueryWrapper<OaUserEntity>()
                .select("id")
                .eq("openid", openid)
                .last("limit 1"));
        if (user != null) {
            return user.getId();
        }
        return null;
    }

}
